package cn.xdd._10PriorityQueue;

import cn.xdd.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * @author user_xdd
 * @Date 2022-05-10 13:29
 * @description
 *   消费设置有优先级的代码
 *      会第一个收到5号消息
 * @return
 */
public class Comsumer {
    private final static String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        DeliverCallback Callback = (consumerTag, delivery) -> {
            String receivedMessage = new String(delivery.getBody());
            System.out.println("接收到消息:" + receivedMessage);
        };
        CancelCallback cancelCallback = (consumerTag) -> {
            System.out.println(consumerTag + "消费者取消消费接口回调逻辑");
        };
        System.out.println(" c1 消费者启动等待消费 ");
        channel.basicConsume(QUEUE_NAME, true, Callback, cancelCallback);

    }


}
